package com.ewo.controller;

import com.ewo.entity.ResponseResult;
import com.ewo.entity.User;
import com.ewo.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;
    @GetMapping("/findAllUser")
    public ResponseResult findAllUser(){
        List<User> userList = userService.findAllUser();
        return ResponseResult.ok(userList);
    }

    //添加User用户
    @PostMapping("/addUser")
    public ResponseResult addUser(@RequestBody User user){
        //User user = new User("张三", "123456", 20);
        int rows = userService.addUser(user);
        return rows==0?ResponseResult.fail():ResponseResult.ok(null);
    }

}
